/* vim: set ts=2 et sw=2 cindent fo=qroca: */

package com.globant.google.mendoza.malbec;

import com.globant.google.mendoza.malbec.schema._2.MerchantCalculationCallback;
import com.globant.google.mendoza.malbec.schema._2.ShoppingCart;

/** The GBuy merchant calculation callback.
 */
public interface CalculationListener {

  /** Called when a new message is received, before the acknowledge is sent to
   * GBuy.
   *
   * @param command The command name. This is the top level xml node name.
   *
   * @param orderNumber The GBuy order number.
   *
   * @param timestamp The notification timestamp.
   */
  /*
  void receiveMessage(final String command, final String orderNumber, final
      Date timestamp);
      */

  /** Called when GBuy requests a merchant calculation.
   *
   * @todo Verify if the buyerId can be null for the
   * merchantCalculationCallback.
   *
   * @param buyerId The GBuy assigned buyer unique identifier. Typically,
   * you'll use this value to validate one-time-use coupons. Currently, this
   * element is never null, but it might not be the case in future kinds of
   * merchant callbacks.
   *
   * @param cart A copy of the shopping-cart that was posted when the order was
   * created.
   *
   * @param language Language used for the buyer's user interface, determined
   * by the buyer's browser language setting at signup time. Currently, this is
   * always en_US.
   *
   * @param callback Contains information about the items to be calculated.
   *
   * @return Returns a MerchantCalculationResult or a String with the result of
   *  the requested calculations.
   */
  Object calculate(final Long buyerId, final ShoppingCart
      cart, final String language, final MerchantCalculationCallback callback);
}

